using ASP;
using HoWave.Web.Shop;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class AreaSearch : Shop, IRequiresSessionState
{
	protected UserControls_cmpy_Top Top1;
	protected TextBox txtSearchCity;
	protected Button btnSeach_City;
	protected Literal ltrIsCommandProduct;
	protected UserControls_CMYP_Foot Foot1;
	protected HtmlForm form1;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.GetEliteProduct();
		}
	}
	private void GetEliteProduct()
	{
		DataTable dataTable = this.conn.GetDataTable("select  top 8 *,\r\n                            (select count(*) from dbo.HLShop_OrderItem as c \r\n                            join HLShop_Order as d \r\n                            on c.ProductID=a.ProductID and  c.OrderFormNum=d.OrderFormNum  and d.PayStatus=1) as SaleCount\r\n                            from HLShop_Product as a \r\n                            where EnableSale=1 and Stocks>0 and EnableSingleSell=1 and IsApprove=1 and IsElite=1 \r\n                            and  ProductSmallImageUrl is not null   and ProductSmallImageUrl !=''\r\n                            order by OnTop Desc,IsHot Desc");
		for (int i = 0; i < dataTable.Rows.Count; i++)
		{
			if (i == 0)
			{
				this.ltrIsCommandProduct.Text = string.Concat(new object[]
				{
					"<dt><a href='ShowProduct.aspx?ProductID=",
					dataTable.Rows[i]["ProductID"].ToString(),
					"' target='_blank'><span>",
					i + 1,
					"</span><strong>",
					this.GetProductName(dataTable.Rows[i]["ProductName"].ToString()),
					"</strong></a><img src='",
					dataTable.Rows[i]["ProductSmallImageUrl"].ToString(),
					"'  width='169' height='144' ></dt>"
				});
			}
			else
			{
				Literal expr_E3 = this.ltrIsCommandProduct;
				object text = expr_E3.Text;
				expr_E3.Text = string.Concat(new object[]
				{
					text,
					"<dd><span>",
					i + 1,
					"</span><a href='ShowProduct.aspx?ProductID=",
					dataTable.Rows[i]["ProductID"].ToString(),
					"' target='_blank'>",
					this.GetProductName(dataTable.Rows[i]["ProductName"].ToString()),
					"</a></dd>"
				});
			}
		}
		dataTable.Dispose();
	}
	public string GetProductName(string name)
	{
		string result;
		if (name.Length > 10)
		{
			name = name.Substring(0, 10) + "...";
			result = name;
		}
		else
		{
			result = name;
		}
		return result;
	}
	protected void btnSeach_City_Click(object sender, EventArgs e)
	{
		base.Response.Redirect("~\\productlist.aspx?city=" + this.txtSearchCity.Text.Trim());
	}
}
